package yf.platform.ctl;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import yf.platform.biz.Service;
import yf.platform.dao.DaoSupport;
import yf.platform.dao.JfinalDaoSupport;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

@Controller
public class CoreCtl {

	private static final Logger logger = LogManager.getLogger(CoreCtl.class);

	@RequestMapping(value = "c",method = RequestMethod.GET)
	public void c(@RequestParam Map map,HttpServletRequest request, HttpServletResponse response) {
		logger.debug(map.toString());
		//获取到service
		Service s = Service.build(map.get("s").toString());
		try {
			s.execute(map,request,response);
		} catch (Throwable e) {
			e.printStackTrace();
		}
	}


	@RequestMapping(value = "login",method = RequestMethod.GET)
	public String login() {

		return "login";
	}

	@RequestMapping(value = "login",method = RequestMethod.POST)
	public String doLogin() {

		return "redirect:main/index";
	}

}
